{% extends layout %}

{% block content %}
<link href="/dist/css/BigCMSEdit.css" rel="stylesheet">
<!-- bootstrap-validation -->
<link href="/components/form.validation/dist/css/formValidation.css" rel="stylesheet">
<script src="/components/form.validation/dist/js/formValidation.js"></script>
<script src="/components/form.validation/dist/js/framework/bootstrap.js"></script>

<script type="text/javascript" charset="utf-8" src="/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/plugins/ueditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
    var FPH = new FormPageHelper({ModelName:'Content',entity: '{{entity|dump(0)|safe}}' });
</script>
<script>
    $(function(){
        //实例化编辑器
        //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
        var ue = UE.getEditor('editor');
        
        var FVSettings ={
            title: {
                row: '.col-sm-6',
                validators: {
                    notEmpty: {
                        message: '标题不能为空'
                    }
                }
            },
            sort: {
                row: '.col-sm-6',
                validators: {
                    notEmpty: {
                        message: '排序不可为空'
                    },
                    integer: {
                        message: '排序必须为整数'
                    }
                }
            }
        };
        FPH.initFormValidation(FVSettings);
        FPH.initFormData();
    });
</script>
<div class="row">
    <div class="col-xs-12">
        <div class="box box-warning">
            <div class="box-header with-border">
                <h3 class="box-title">{{title}}菜单</h3>
            </div>
            <form id="MainForm">
                {% if entity._id %}
                    <input type="hidden" name="_id" value="{{entity._id}}" />
                {% endif %}
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-12"><span style="color:red;">*</span>内容名称</label>
                        <div class="col-sm-6">
                            <input type="text" name="title" class="form-control">
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-12"><span style="color:red;">*</span>菜单排序</label>
                        <div class="col-sm-6">
                            <input type="text" name="sort" class="form-control">
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-12"><span style="color:red;">*</span>内容</label>
                        <div class="col-sm-6">
                            <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
                        </div>
                        <div class="col-sm-6 error"></div>
                    </div>

                    
                    <div class="col-md-12">
                        <input type="button" class="btn btn-danger submit" style="margin-right:30px; width: 60px" value="保存" />
                        <input class="btn btn-default cancel" style="width:60px" type="button" value="返回" />
                    </div>
                    <div class="clearfix"></div>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}